from .context import Context


class Rule:

    def __init__(self, keywords: set) -> None:
        self.keywords = keywords

    def scan(self, context: Context):
        pass

    def _navigate_urls_ok(self, context: Context):
        # TODO: 检测跳转url是否为本域
        pass

    def _jsevents_ok(self, context: Context):
        # TODO: 检测js事件
        def _eval_ok():
            # TODO:检测eval
            pass

        def _write_ok():
            # TODO:检测write,writeln
            pass

        def _title_ok():
            # TODO:检测title
            pass

        pass

    def _a_ok(self, context: Context):
        # TODO: 检测a标签中是否有敏感词
        # TODO: 检测a标签中不可见的外域跳转是否有敏感词
        #       1. 通过el.getBoundingClientRect()获取大小和位置
        #       2. 通过截图判断page.locator(".header").screenshot(path="screenshot.png")
        pass

    def _html_ok(self, html: str):

        def _html_title_ok():
            # TODO: 检测原始html中title是否含为html实体编码
            pass

        def _html_vba_ok():
            # TODO: 检测html是否有vba标签
            pass

        pass

    def _iframe_html_ok(self, context: Context):
        # TODO: 检测iframe的html内存
        pass

    def _outside_request_urls_ok(self, context: Context):
        # TODO: 检测外部资源
        pass

    def _iframe_urls_ok(self, context: Context):
        # TODO: 检测iframe的url
        pass
